using System;
using System.Collections.Generic;
using System.Text;
using ENTITIES;
using DAL;
using Utility;

namespace BUS
{
public    class HinhSanPhamBUS
    {
    
        public static void Insert(TBHinhSanPham hinhsanpham)
        {
            HinhSanPhamDAL hinhsanphamDAL = new HinhSanPhamDAL();
            hinhsanphamDAL.Insert(hinhsanpham);
        }
        public static void Update(TBHinhSanPham hinhsanpham)
        {
            HinhSanPhamDAL hinhsanphamDAL = new HinhSanPhamDAL();
            hinhsanphamDAL.Update(hinhsanpham);
        }
        public static void Delete(int iD)
        {
            HinhSanPhamDAL hinhsanphamDAL = new HinhSanPhamDAL();
            hinhsanphamDAL.Delete(iD);
        }
        public static tbHinhSanPhamCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            HinhSanPhamDAL hinhsanphamDAL = new HinhSanPhamDAL();
            return hinhsanphamDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbHinhSanPhamCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhSanPhamDAL hinhsanphamDAL = new HinhSanPhamDAL();
            return hinhsanphamDAL.Get(cri.Criter, 0, 0, tbHinhSanPhamColumns.MaHinh.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static TBHinhSanPham GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbHinhSanPhamColumns.MaHinh.ToString(), Condition.EQUAL, iD);
            HinhSanPhamDAL hinhsanphamDAL = new HinhSanPhamDAL();
            tbHinhSanPhamCollection hinhsanphamcollection = hinhsanphamDAL.Get(cri.Criter,
                  0, 0, tbHinhSanPhamColumns.MaHinh.ToString(), OrderDirection.ASC.ToString(), out total);
            if (hinhsanphamcollection.Count > 0)
                return hinhsanphamcollection[0];
            return null;
        }
        public static tbHinhSanPhamCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhSanPhamDAL hinhsanphamDAL = new HinhSanPhamDAL();
            return hinhsanphamDAL.Get(cri.Criter, 1, number,
             tbHinhSanPhamColumns.MaHinh.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbHinhSanPhamCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhSanPhamDAL hinhsanphamDAL = new HinhSanPhamDAL();
            return hinhsanphamDAL.Get(cri.Criter, 1, number,
               tbHinhSanPhamColumns.MaHinh.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    }

